import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Login from '../views/Login.vue'
import Index from '../views/Index.vue'
import Essay from '../views/board/Essay.vue'
import Type from '../views/board/Type.vue'
import Firend from '../views/board/Firend.vue'
import Admin from '../views/board/Admin.vue'
import Project from '../views/board/Project.vue'
import EssayEdit from '../views/board/EssayEdit.vue'
Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path:'/login',
    name:'Login',
    component:Login
  },
  {
    path:'/',
    name:'Index',
    component:Index,
    redirect:'essay',
    children:[
      {
        path:'essay',
        name:'Essay',
        component:Essay
      },
      {
        path:'type',
        name:'Type',
        component:Type
      },
      {
        path:'firend',
        name:'Firend',
        component:Firend
      },
      {
        path:'admin',
        name:'Admin',
        component:Admin
      },
      {
        path:'project',
        name:'Project',
        component:Project
      },
      {
        path:'essayedit',
        name:'EssayEdit',
        component:EssayEdit
      }
    ]
  },
  {
    path: '/hoe',
    name: 'Home',
    component: Home
  },
  
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
